{# SPDX-License-Identifier: Apache-2.0 -#}

{% extends "admin/base.html" %}

{% import "admin/utils/pagination.html" as pagination %}

{% block title %}IP Addresses{% endblock %}

{% block breadcrumb %}
  <li class="breadcrumb-item active">IP Addresses</li>
{% endblock %}

{% block content %}
<div class="card">
  <div class="card-body table-responsive p-0">
    <table class="table table-striped table-hover">
      <thead>
      <tr>
        <th>IP Address</th>
        <th>Hashed IP Address</th>
        <th>Last Seen Geo</th>
        <th>Banned?</th>
        <th>Ban Date</th>
        <th>Ban Reason</th>
      </tr>
      </thead>
      <tbody>
      {% for ip_address in ip_addresses %}
      <tr>
        <td>
          <a href="{{ request.route_path('admin.ip_address.detail', ip_address=ip_address.ip_address) }}">{{ ip_address.ip_address }}</a>
        </td>
        <td>{{ ip_address.hashed_ip_address }}</td>
        <td>{{ ip_address.geoip_info }}</td>
        <td>{% if ip_address.is_banned %}<i class="fa fa-check text-red"></i>{% endif %}</td>
        <td>{{ ip_address.ban_date }}</td>
        <td>{{ ip_address.ban_reason.value }}</td>
      </tr>
      {% endfor %}
      </tbody>
    </table>
  </div>

  <div class="card-footer">
    <div class="row">
      <div class="col-sm-5">
        {{ pagination.summary(ip_addresses) }}
      </div>

      <div class="col-sm-7">
        <div class="float-right">
          {{ pagination.paginate(ip_addresses) }}
        </div>
      </div>
    </div>
  </div>

</div>
{% endblock content %}
